1. Technology Field
The invention relates to a data merging method for a rewritable non-volatile memory module, and a memory controller and a memory storage apparatus using the same.
2. Description of Related Art
Along with quick development of digital cameras, mobile phones and MP3, demand for storage media by customers is increased greatly. Since a rewritable non-volatile memory has advantages of data non-volatility, energy saving, small size, none mechanical structure and fast accessing rate, etc., it is suitable for portable electronic products, for example, notebook computers. A solid state disk (SSD) is a storage device using the flash memory as a storage medium. Therefore, the flash drive industry becomes popular in the electronics industry recently.
The flash memory module has a plurality of physical blocks, and each physical block has a plurality of physical pages, wherein when data is written into the physical block, it has to be sequentially written according to a sequence of the physical pages. Moreover, the physical pages written with data have to be erased first for again writing data thereon. Particularly, the physical block is the smallest unit that can be erased, and the physical page is the smallest unit that can be programmed (written). Therefore, in management of the flash memory module, the physical blocks are generally grouped into a data area and a free area.
The physical blocks of the data area (which are also referred to as data physical blocks) are used for storing data stored by a host system. In detail, a memory management circuit converts a logical access address accessed by the host system into a logical page of a logical block, and maps the logical page of the logical block to a physical page of a physical block of the data area. Namely, in management of the flash memory module, the physical blocks of the data area are regarded as used physical blocks (for example, stored with data written by the host system). For example, the memory management circuit may use a logical block-physical block mapping table to record a mapping relationship between the logical blocks and the physical blocks of the data area, wherein the logical pages of the logical block sequentially correspond to the physical pages of the mapped physical block.
The physical blocks of the free area (which are also referred to as free physical blocks) are used to substitute the physical blocks of the data area. In detail, as described above, the physical block written with data has to be erased first for again writing data thereon, and the physical blocks of the free area are designed to be written with updated data to substitute the physical blocks originally mapped to the logical blocks. Therefore, the physical blocks in the free area are empty or available physical blocks, i.e. physical blocks that are not stored with data or physical blocks stored with data marked to be invalid.
Namely, the physical pages of the physical blocks of the data area and the free area are used to map to the logical pages of the logical blocks in an alternating manner, so as to store the data written by the host system.
For example, when a logical access address to be written with update data by the host system corresponds to a certain logical page of a certain logical block of the storage apparatus, the memory management circuit of the storage apparatus obtains a physical block from the free area to serve as a log physical block corresponding to the logical block, and writes the update data into the physical pages of the log physical block, so as to shorten a time for executing a write command. Then, when the physical blocks of the free area is to be exhausted, the memory management circuit performs a data merging procedure to the logical block. For example, in the data merging procedure, the memory management circuit may get a physical block from the free area to serve as a new data physical block, and writes all latest page data belonging to the logical block to the new data physical block, and re-maps the logical block to the new data physical block.
As described above, in the data merging procedure, the memory management circuit has to move (i.e. copy) all data belonging to the same logical block to an empty physical block. Therefore, the data merging procedure is time-consuming and influences a data accessing performance of the flash memory storage apparatus. Therefore, it is an important issue to shorten the time required for performing the data merging procedure.
Nothing herein should be construed as an admission of knowledge in the prior art of any portion of the present invention. Furthermore, citation or identification of any document in this application is not an admission that such document is available as prior art to the present invention, or that any reference forms a part of the common general knowledge in the art.